package com.kaizige.realtor.Controller;

import com.kaizige.realtor.Dao.messageDao;
import com.kaizige.realtor.Dao.payDao;
import com.kaizige.realtor.Dao.recordDao;
import com.kaizige.realtor.Pojo.message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class payController {
	@Autowired
	recordDao rd;
	@Autowired
	messageDao md;
	@Autowired
	payDao pd;
	@PostMapping("tenActPay/{id}/{house_id}")
	public String tenActPay(@PathVariable("id")int id, @PathVariable("house_id")int house_id, HttpSession session){
		rd.upRecSta(id);
		String user = (String)session.getAttribute("LoginUser");
		pd.paySeeHou(user);
		String content = "租客" + user + "申请了看房，房间号：" + house_id;
		message m = new message(user,"tenant","admin1","manager",content);
		md.tenToManSeeHou(m);
		return "redirect:/tenSeeHou";
	}
	
	@RequestMapping("tenDelPay/{id}")
	public String tenDelPay(@PathVariable("id")int id){
		rd.delRec(id);
		return "redirect:/tenSeeHou";
	}
	
}
